set_error_output

This function logs a list of internal errors set by the engine during the script's execution and writes them to a specified file.

bool set_error_output(string filename)

Parameters:
filename
The name of the file to write to.

Return value:
true on success, false on failure.

Remarks:
If an internal error is encountered while this function is active, it will print the engine function that produced the error, the error description, and the stack trace of the script into the log file of your choice. This is useful for debugging whether certain unexpected error conditions are being met and are not accounted for in the script.

Please note that runtime errors are not accounted for, only errors that can be retrieved from within the script with the get_last_error or get_last_error_text functions.

For this function to work accurately throughout the whole script's execution, it is recommended to call it before calling any other function, in the beginning of main.

Example:
// Generate a bunch of error conditions and have the program log them.

void main()
{
timer error;
sound test;
file whatever;
set_error_output("errors.log");
whatever.open("test.temp.txt", "wb");
whatever.write("This is a test.\r\n");
whatever.close();
whatever.open("test.temp.txt", "rb");
whatever.write("This shouldn't work.\r\n"); // This should generate an error because the file is opened for reading.
whatever.close();
file_delete("test.temp.txt");
test.stream("z:\\whatever.mp3.ogg.wav"); // This should generate an error, because this file probably doesn't exist.
error.pause();
error.pause(); // This should generate an error, since the timer is already paused.
directory_delete("z:/this/directory/should/not/exist/at/all"); // This should generate yet another nice error to log.
}